Skip to content

Conversation

@Andarist
Copy link
Contributor

@Andarist Andarist commented Mar 4, 2025

fixes #61347

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Mar 4, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 4, 2025
const name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
const expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected);
return !!expected && (isLiteralType(expected) || isPatternLiteralType(expected)) && !isTypeAssignableTo(getTypeOfNode(property), expected);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the logic in createUnionOrIntersectionProperty here. This HasLiteralType is required for Discriminant:

Discriminant = HasNonUniformType | HasLiteralType,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Intellisense doesn't narrow properly when discriminator is a template literal

2 participants